<template>
  <view class="input-area">
    <view class="input-toolbar">
      <button class="tool-btn" @click="$emit('show-emoji')">😊</button>
      <button class="tool-btn" @click="$emit('choose-image')">📷</button>
      <button class="tool-btn" @click="$emit('choose-file')">📎</button>
      <button class="tool-btn" @click="$emit('show-voice')">🎤</button>
    </view>
    <view class="input-row">
      <input 
        class="message-input" 
        :value="value" 
        placeholder="输入消息..."
        @input="handleInput"
        @confirm="$emit('send')"
        @focus="$emit('focus')"
      />
      <button 
        class="send-btn" 
        @click="$emit('send')"
        :disabled="!value.trim()"
      >
        发送
      </button>
    </view>
  </view>
</template>

<script>
export default {
  name: 'MessageInput',
  props: {
    value: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleInput(e) {
      this.$emit('input', e.detail.value)
    }
  }
}
</script>

<style scoped>
.input-area {
  flex-shrink: 0;
  width: 100%;
  background: white;
  border-top: 1rpx solid #f0f0f0;
  padding: 12rpx 20rpx 12rpx 20rpx;
  box-sizing: border-box;
}

.input-toolbar {
  width: 100%;
  display: flex;
  gap: 16rpx;
  margin-bottom: 12rpx;
}

.tool-btn {
  width: 60rpx;
  height: 60rpx;
  flex-shrink: 0;
  border-radius: 50%;
  background: #f5f5f5;
  border: none;
  font-size: 28rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.tool-btn:active {
  background: #e8e8e8;
}

.input-row {
  width: 100%;
  display: flex;
  gap: 12rpx;
  align-items: center;
}

.message-input {
  flex: 1;
  height: 60rpx;
  background: #f5f5f5;
  border-radius: 30rpx;
  padding: 0 24rpx;
  font-size: 26rpx;
  color: #333;
  line-height: 60rpx;
}

.send-btn {
  flex-shrink: 0;
  height: 60rpx;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 30rpx;
  padding: 0 28rpx;
  font-size: 26rpx;
  font-weight: bold;
  line-height: 60rpx;
}

.send-btn:disabled {
  opacity: 0.5;
}

.send-btn:active:not(:disabled) {
  opacity: 0.8;
}
</style>

